package cn.bigfire.wedesk.net.initializer;

import cn.bigfire.wedesk.net.codec.ProtocolDecoder;
import cn.bigfire.wedesk.net.codec.ProtocolEncoder;
import cn.bigfire.wedesk.net.fivesocket.codec.FiveSocketDecoder;
import cn.bigfire.wedesk.net.fivesocket.codec.FiveSocketEncoder;
import cn.bigfire.wedesk.net.handler.ServerHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.nio.NioSocketChannel;

public class TcpChannelInitializer extends ChannelInitializer<NioSocketChannel> {

    @Override
    protected void initChannel(NioSocketChannel channel) throws Exception {
        channel.pipeline().addLast(new FiveSocketDecoder());//应用层解码器
        channel.pipeline().addLast(new FiveSocketEncoder());//应用层编码器
        channel.pipeline().addLast(new ProtocolDecoder());//业务层解码器
        channel.pipeline().addLast(new ProtocolEncoder());//业务层编码器
        channel.pipeline().addLast(new ServerHandler());
    }


}
